<?php
/**
 * Created by b17
 * 2/15/12 6:20 PM
 */

namespace Managers\Email;

class DefaultFilters implements \Zend_Filter_Interface
{

    /**
     * @var \Zend_Filter_Interface[]
     */
    protected $filters = array();

    public function __construct()
    {
        $this->initFilters();
    }

    protected function initFilters()
    {
        $this->addFilter(new \Zend_Filter_StringToLower());
        $this->addFilter(new \Zend_Filter_StringTrim());
    }

    public function addFilter(\Zend_Filter_Interface $filter)
    {
        $this->filters[] = $filter;
    }

    /**
     * Returns the result of filtering $value
     *
     * @param  mixed $value
     * @throws \Zend_Filter_Exception If filtering $value is impossible
     * @return mixed
     */
    public function filter($value)
    {
        foreach ($this->filters as $filter) {
            $value = $filter->filter($value);
        }
        return $value;
    }
}
